package com.duobaoyu.dby.supply.biz.converter;

import com.alibaba.fastjson.JSON;
import com.duobaoyu.dby.common.core.constant.CommonConstants;
import com.duobaoyu.dby.common.core.convert.bean.ReferenceMapper;
import com.duobaoyu.dby.supply.biz.util.ConverterUtils;
import com.duobaoyu.dby.supply.common.biz.bo.refund.*;
import com.duobaoyu.dby.supply.common.biz.excel.AfterSaleExportData;
import com.duobaoyu.dby.supply.common.biz.vo.refund.AfterSaleExportVO;
import com.duobaoyu.dby.supply.db.entity.refund.*;
import org.mapstruct.Builder;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * Created by shuming on 2023/10/7 15:21
 */
@Mapper(uses = ReferenceMapper.class, imports = {ConverterUtils.class, AfterSaleContactInfoBO.class, CustomerReturnAddressBO.class, JSON.class}, builder = @Builder(disableBuilder = true), componentModel = CommonConstants.COMPONENT_MODEL)
public interface AfterSaleServiceConverter {

    AfterSalePickUp convertAfterSalesPickup(AfterSalePickUpBO pickUp);

    AfterSaleReturn convertAfterSalesReturn(AfterSaleReturnShipmentBO returnWareInfo);

    AfterSaleWayBillOutBO assembleAfterSaleWayBill(AfterSalesLogistic logistics);

    AfterSalePickUpBO assembleAfterSalePickUp(AfterSalePickUp afterSalePickUp);

    List<AfterSalePickUpBO> assembleAfterSalePickUpList(List<AfterSalePickUp> pickUpList);

    AfterSaleReturnShipmentBO assembleAfterSaleReturnShipment(AfterSaleReturn afterSaleReturn);

    List<AfterSaleItemOutBO> assembleAfterSaleItems(List<AfterSaleItem> afterSaleItemList);

    @Mapping(target = "contactInfo", expression = "java(ConverterUtils.parseObject(afterSale.getContactInfo(),AfterSaleContactInfoBO.class))")
    AfterSaleOutBO assembleAfterSale(AfterSale afterSale);

    List<AfterSaleOutBO> assembleAfterSale(List<AfterSale> afterSales);

	@Mapping(target = "afterSaleImageList", expression = "java(JSON.parseArray(afterSaleItem.getAfterSaleImage(), String.class))")
    AfterSaleItemOutBO assembleAfterSaleItem(AfterSaleItem afterSaleItem);

    @Mapping(target = "contactInfo", expression = "java(ConverterUtils.toJsonString(afterSaleCreateIn.getContactInfo()))")
    AfterSale convertAfterSale(AfterSaleCreateInBO afterSaleCreateIn);

    @Mapping(target = "contactInfo", expression = "java(ConverterUtils.toJsonString(modify.getContactInfo()))")
    AfterSale convertAfterSale(AfterSaleModifyInBO modify);

    List<AfterSaleItem> convertAfterSalesItem(List<AfterSaleItemInBO> afterSaleItems);

    @Mapping(target = "afterSaleImage", expression = "java(ConverterUtils.toJsonString(afterSaleItemIn.getAfterSaleImageList()))")
    AfterSaleItem convertAfterSalesItem(AfterSaleItemInBO afterSaleItemIn);

    @Mapping(target = "skuNum", source = "sendingBackQuantity")
    AfterSalesLogistic convertAfterSalesLogistic(AfterSaleWayBillInBO wayBill);

    CustomerReturnAddress convertReturnAddress(CustomerReturnAddressBO customerReturnAddress);

    AfterSaleOutBO assembleAfterSaleOut(AfterSaleOutBO afterSale);

    AfterSaleItemOutBO assembleAfterSaleItemOut(AfterSaleItemOutBO item);

    AfterSaleExportData assembleAfterSaleExportData(AfterSaleExportVO afterSaleExport);
}
